import pytest
import requests
import os
def pytest_sessionfinish(session, exitstatus):
    os.system("allure generate ./temps -o ./report --clean")
@pytest.fixture(scope="session")
def h5login():
    url = "http://192.168.10.142:8081/api/front/login"
    login = {
        "account": "18292417675",
        "password": "crmeb@123456",
        "spread_spid": 0
    }
    response = requests.post(url=url, json=login)
    response.raise_for_status()
    yield response.json()["data"]["token"]

@pytest.fixture(scope="session")
def edit_id(h5login):
    url1 = "http://192.168.10.142:8081/api/front/address/edit"
    editin = {
        "address": {
            "city": "郑州市",
            "cityId": 367396,
            "district": "金水区",
            "province": "河南省"
        },
        "detail": "郑州时代国际广场",
        "id": 0,
        "isDefault": False,
        "phone": "18292417675",
        "realName": "书豪"
    }
    resource1 = requests.post(url=url1, json=editin, headers={"Authori-Zation": f"{h5login}"})
    resource1.raise_for_status()
    print(resource1.json())
    yield resource1.json()["data"]["id"]
# os.system("pytest F:/Longlsland/gitee/H5login --alluredir F:/Longlsland/gitee/H5login/results_2")
# os.system("allure generate F:/Longlsland/gitee/H5login/results_2 --clean -o F:/Longlsland/gitee/H5login/allure-report")
# os.system('pytest Test_allure.py --alluredir ./results_2')
# os.system("allure generate ./pytest_results -o ./allure-report --clean")
